/*mgBVjmwkvoNAq04L4PpN6Vp+uTjoIWUNbmacAQMIS+vxdwNId6FdmY3MWL3PBpZ2*/
import { ajax } from "nc-lightapp-front";
export default function formBeforeEvent(props, moduleId, key, value) {
    let meta = props.meta.getMeta();
    let attr = key;
    var config = {
        itemKey: '',
        DataPowerOperationCode: '',//使用权
        isDataPowerEnable: 'Y',//使用权限
        busifuncode: '',
        AppCode: '',
        orgType: '',
        refnodename: '',//参照显示名称
        accclass: '',
        parentbilltype: '',
        dateStr: '',
        GridRefActionExt: "",
        TreeRefActionExt: "",
        supplier: '',
        customer: '',
        isShowDisabledData: '',
        rate_category_in_value: ''//债权债务仅支持此几类
    }
    let flag = true; //用来控制单元格是否可操作
    let field = ['m_sToObBm','pk_ratetype','ratedate','m_dBbhl'];
    if (field.indexOf(key)!=-1) {
        meta[moduleId].items.map((item) => {
            var attrcode = item.attrcode;
            if (attr == attrcode) {
                if (attrcode == 'm_sToObBm') {
                    var zrObject = props.form.getFormItemsValue("form", "m_izrWldx");
                    if (zrObject.value == '0') {
                        item.itemtype = 'refer'
                        item.refcode = 'uapbd/refer/customer/CustomerDefaultTreeGridRef/index'
                        item.queryCondition = (p) => {
                            return {
                                DataPowerOperationCode: 'fi', //使用权组
								isDataPowerEnable: 'Y',
								pk_org: this.state.pk_org
                            }
                        }
                        return item;
                    } else if (zrObject.value == '1') {
                        item.itemtype = 'refer'
                        item.refcode = 'uapbd/refer/supplier/SupplierRefTreeGridRef/index'
                        item.queryCondition = (p) => {
                            return {
                                DataPowerOperationCode: 'fi', //使用权组
								isDataPowerEnable: 'Y',
								pk_org: this.state.pk_org
                            }
                        }
                        return item;

                    } else if (zrObject.value == '2') {
                        item.itemtype = 'refer'
                        item.refcode = 'uapbd/refer/org/DeptTreeRef/index'
                        item.queryCondition = (p) => {
                            return {
                                DataPowerOperationCode: 'fi', //使用权组
								isDataPowerEnable: 'Y',
								pk_org: this.state.pk_org
                            }
                        }
                        return item;
                    } else if (zrObject.value == '3') {
                        item.itemtype = 'refer'
                        item.refcode = 'uapbd/refer/psninfo/PsndocTreeGridRef/index'
                        item.queryCondition = (p) => {
                            return {
                                DataPowerOperationCode: 'fi', //使用权组
								isDataPowerEnable: 'Y',
								pk_org: this.state.pk_org
                            }
                        }
                        return item;
                    }
                }
                else if (attrcode == 'pk_ratetype' || attrcode == 'ratedate'||attrcode=='m_dBbhl') {
                    ajax({
                        url: '/nccloud/arap/ref/ratecontrol.do',
                        async: false,
                        data: {
                            pk_org: this.state.pk_org,
                            pk_currtype: this.state.m_sCurrency,
                            ratekey: attrcode,
                            rateType: props.form.getFormItemsValue('form', 'pk_ratetype')?props.form.getFormItemsValue('form', 'pk_ratetype').value : "debTransfer",
                            src_syscode: '1'
                        },
                        success: (res) => {
                            if (res.success) {
                                props.form.setFormItemsDisabled('form', {[attrcode]: !res.data,});
                                
                            }
                        }
                    });
                    if (attrcode == 'pk_ratetype') {
                        item.queryCondition = (p) => {
                            config.rate_category_in_value = '(0,1,2,5,7)';
                            return config;
                        }
                    }


                }
            }

        });
    }

    props.meta.setMeta(meta);
}

/*mgBVjmwkvoNAq04L4PpN6Vp+uTjoIWUNbmacAQMIS+vxdwNId6FdmY3MWL3PBpZ2*/